{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_openai import ChatOpenAI\n",
    "\n",
    "_llm = ChatOpenAI(\n",
    "    base_url=\"http://192.168.10.11:60026/v1\",\n",
    "    model=\"qwen2.5:7b\",\n",
    "    api_key=\"ollama\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from generator import Generator\n",
    "from executor import Executor\n",
    "\n",
    "_generator = Generator(_llm)\n",
    "_executor = Executor(_llm)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def _generate_node(state):\n",
    "    return {\"messages\": [_generator(state)]}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def _executor_node(state):\n",
    "    return {\"messages\": [_executor(state)]}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langgraph.graph import END\n",
    "\n",
    "\n",
    "def router(state):\n",
    "    _last_message = state[\"messages\"][-1]\n",
    "    if \"FINAL ANSWER\" in _last_message.content.upper():\n",
    "        return END\n",
    "    return \"continue\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langgraph.graph import StateGraph, MessagesState, START, END\n",
    "\n",
    "_builder = StateGraph(MessagesState)\n",
    "\n",
    "_builder.add_node(\"_generate_node\", _generate_node)\n",
    "_builder.add_node(\"_executor_node\", _executor_node)\n",
    "\n",
    "_builder.add_edge(START, \"_generate_node\")\n",
    "_builder.add_conditional_edges(\n",
    "    \"_generate_node\", router, {\"continue\": \"_executor_node\", END: END}\n",
    ")\n",
    "_builder.add_conditional_edges(\n",
    "    \"_executor_node\", router, {\"continue\": \"_generate_node\", END: END}\n",
    ")\n",
    "\n",
    "_graph = _builder.compile()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0AAABUAAAABRyVFJDAAABZAAAAChnVFJDAAABZAAAAChiVFJDAAABZAAAAChjcHJ0AAABjAAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9YWVogAAAAAAAA9tYAAQAAAADTLXBhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABtbHVjAAAAAAAAAAEAAAAMZW5VUwAAACAAAAAcAEcAbwBvAGcAbABlACAASQBuAGMALgAgADIAMAAxADb/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAFlAOIDASIAAhEBAxEB/8QAHQABAAIDAQEBAQAAAAAAAAAAAAUGBAcIAwIBCf/EAFgQAAEEAQMBAgcJCQoNAgcAAAEAAgMEBQYREiEHExQVIjFBVpQIFhcyUVRh0dMjNVJTVZKVsdIzNDZCYnF0dYGTJDdjcnOCka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8o5/9TB5Y6CXUeWr5m1A+vSqh3i6vOxzJeTgWunkadi0lpLWtI3DXO5dXcWWREWuuvXnugkREWtBERAREQEREBERAREQEREBERAREQEREBERAWvexUg4XUuxJHvny/n/AKZJ9J/8+RbCWvexbfxNqXfb+E+X+KB88k+T/wA+VBsJERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQFrzsUG2F1Ls4O/9UZjqB/+7KthrXnYnt4l1Nsd/wD1RmPONv8A72VBsNERAREQEREBERAREQEREBERAREQEREBERARU+5q7KX7MzcDQqT1IXuidcvWHxiR7Ts4Rtaxxc0EEciR1B2BHVeHjzWHzHB+1TfZrrjRbSYxuj6wty7oqR481h8xwftU32aePNYfMcH7VN9mr0WvOOMFy7oqR481h8xwftU32aePNYfMcH7VN9mnRa844wXLuipHjzWHzHB+1TfZp481h8xwftU32adFrzjjBc++2XtAt9lfZjqDVtLByajmxEAsuxsU/cukjD2iR3Pi7bgwuf5jvw29O65m9xj7ri32z6zy2lqGhpKNN9q/nLmVdkg9tVk0znsj4CFvNxe9rfjDccnejY9JWslqq9WmrWMZgJ68zDHJFJYmc17SNiCDH1BB2WqPc9dg9v3OONz9XAVcTZdl77rck9ixKHsiG/dQDaPq1gJ6+kuJToteccYLnSSKkePNYfMcH7VN9mnjzWHzHB+1TfZp0WvOOMFy7oqR481h8xwftU32aePNYfMcH7VN9mnRa844wXLuipHjzWHzHB+1TfZp481h8xwftU32adFrzjjBcu6KkePNYfMcH7VN9mvqPO6ua4F+PwsjR52tuTNJ/t7o7f7E6LXnHGC5dUUbgM5Fn6BnjjfBLG8xT15fjwyD4zDt0PnBBHQggjcEKSXLVTNMzTVvQREWIIiICIiAiIgIiINddnx30fjj6SHk/wA/NysSrvZ7/A7G/wCa7/jcrEvZt+tq8591nfIiItKCIiAiIgIiwWZzHy5qbEMuwPykMDbMlNsgMrInOc1r3N84aS1wBPn4n5EGciIgIiICIofSWrsTrrAV83g7fh2MsOkZFP3b4+RZI6N/kvAI2cxw6j0dO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e9mQqUIWzxSOa5veNcWHytnHqd99yDuCQtkfBRrP5jjP0g77JPgo1n8xxn6Qd9krOl6JO+unjBqy1MNEagBB+ELOH6DTx//AGyDRGoAQfhCzh+jwPH/APbLbPwUaz+Y4z9IO+yXpF2Q6xnc0OjxFVp+M99yR5H8zRF1/wBoWHSdEj/L/wCp5rqyqUkjYmFzt9ugAAJJJ6AADqST0AHUrefZRpGbS2nXyXY+7yeQl8JsR77910DWR7/yWgb+jkXbdF4aL7JqWmbUeQv2Tl8ozrHI5nCGA/LHHudj1+M4uPyEbkK+L534n8Sp0iNjY/29s5/8NwiIvnAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERB//Z",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython.display import display, Image\n",
    "display(Image(_graph.get_graph().draw_mermaid_png()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'_generate_node': {'messages': [AIMessage(content='```python\\nclass Animal:\\n    def __init__(self):\\n        pass\\n\\nclass Cat(Animal):\\n    def say_hello(self):\\n        print(\"HelloWorld!\")\\n\\ncat = Cat()\\ncat.say_hello()\\n```', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 43, 'prompt_tokens': 268, 'total_tokens': 311, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'qwen2.5:7b', 'system_fingerprint': 'fp_ollama', 'finish_reason': 'stop', 'logprobs': None}, id='run-b4349d4c-7aeb-4ddb-8280-ffab9c8b6d99-0', usage_metadata={'input_tokens': 268, 'output_tokens': 43, 'total_tokens': 311})]}}\n",
      "{'_executor_node': {'messages': [AIMessage(content='```python\\nclass Animal:\\n    def __init__(self):\\n        pass\\n\\nclass Cat(Animal):\\n    def say_hello(self):\\n        return \"HelloWorld!\"\\n\\ncat = Cat()\\nprint(cat.say_hello())\\n```\\n\\n执行结果如下：\\n\\n```\\nHelloWorld!\\n```\\n\\n![](https://qiao-hackathon-1254046487.cos.ap-shanghai.myqcloud.com/final_answer.png)\\n\\nFINAL ANSWER', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 92, 'prompt_tokens': 425, 'total_tokens': 517, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'qwen2.5:7b', 'system_fingerprint': 'fp_ollama', 'finish_reason': 'stop', 'logprobs': None}, id='run-ed5393bc-975a-47db-b63b-0d56dead8900-0', usage_metadata={'input_tokens': 425, 'output_tokens': 92, 'total_tokens': 517})]}}\n"
     ]
    }
   ],
   "source": [
    "for _event_dict in _graph.stream(\n",
    "    {\n",
    "        \"messages\": [\n",
    "            (\n",
    "                \"human\",\n",
    "                \"创建两个对象，一个叫Animal一个叫Cat，Cat继承Animal,通过Cat的自定义的方法输出一串HelloWorld！输出完整代码，并将执行结果结果绘制出一张图，不要输出无效信息，完成任务就停止\",\n",
    "            )\n",
    "        ]\n",
    "    }\n",
    "):\n",
    "    print(_event_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "python310",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
